<!-- 文本域 -->
<template>
	<view class='ws-textarea'>
		<textarea :disable-default-padding="true" :value='value' :maxlength="maxlength" :auto-height='autoHeight' :placeholder="placeholder" :placeholder-class='placeholderClass' @input='handleInput'></textarea>
	</view>
</template>

<script>
	export default {
		name:"ws-textarea",
		props: {
			value: String,
			maxlength: {
				type: Number,
				default: 140
			},
			placeholder: {
				type: String,
				default: '请输入'
			},
			placeholderClass: String,
			autoHeight: Boolean
		},
		data() {
			return {
				
			};
		},
		methods: {
			handleInput(e) {
				let val = e.detail.value;
				if(val.length > this.maxlength) {
					val = val.substring(0, this.maxlength)
				}
				this.$emit('input', val);
			}
		}
	}
</script>

<style lang="scss" scoped>
.ws-textarea, .ws-textarea textarea {
	width: 100%;
	height: 100%;
}
</style>